<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title></title>
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<link rel="stylesheet" type="text/css" href="/static/shop/account/css/style.css"/>
	<link rel="stylesheet" type="text/css" href="/static/shop/account/css/swiper.min.css"/>
	<link rel="stylesheet" href="/static/shop/account/css/LCalendar.css">
</head>
<body>
<div class="login">
	<a href="{:url('/')}" title="首页">
		<img style = 'width: 9rem;
    margin-top: 1rem;'src="__MODULE_IMG__/logo.png">
	</a>
	<ul>
		{notempty name='user'}
		<!--<a href="/account/update/" title="" class="ucter">
            欢迎  {$user.mobile}
        </a>
        <span class="separate">|</span>-->
		<a href="{:url('shop/account/index')}" title="个人中心">个人中心</a>
		<span class="separate">|</span>
		<!--
                        <a href="{:url('shop/account/love')}" title="我的关注">我的关注</a>

                        <span class="separate">|</span>
                        <a href="{:url('shop/artwork/cart')}" title="购物车">购物车</a>
                        <span class="separate">|</span>-->
		<a href="{:url('shop/login/logout')}" title="退出">退出</a>
		{else/}

		<li><a href="{:url('shop/login/index')}" title="登录">登录</a></li>
		<li>|</li>
		<li><a href="{:url('shop/login/register')}" title="注册">注册</a></li>
		{/notempty}
	</ul>
</div>

{include file="public:nav"/}
{include file="public:menu"/}

<ul class="index_xuan">
	<li ><a href="{:url('shop/account/userinformation')}" style="color:#FFFFFF;">账户信息</a></li>
	<li>认证信息</li>
	<li><a href="{:url('shop/like/index')}" style="color:#FFFFFF;">我的喜好</a></li>
	<li class="bor">收货地址</a></li>
</ul>

<div class="inp">
	<p>国家：
		<select id="s1" onchange="getCountry()" ><option>请选择国家</option></select>
	</p>
	<p>省份：
		<select id="s2" onchange="getProvince()" style="display: none"><option>省份、州</option></select>
		<select id="id_provSelect" name="provSelect" style="display: none;" onChange="getChinaProv(this.value);">
			<option>请选择省份</option>
		</select>
	</p>
	<p>地级市、县：
		<select id="s3" style="display: none"><option>地级市、县</option></select>
		<select id="id_citySelect" name="citySelect"
				style="display: none;" onChange="getChinaCity(this.value);"><option>请选择城市</option></select>
	</p>
	<p>收货人姓名：
		<input type="text" id="name" value="" style="">
		<small style="color:red;">(必填)</small>
	</p>
	<p>详细地址：
		<input type="text" id="address1" value="" style="">
		<small style="color:red;">(必填)</small>
	</p>
	<p>标志建筑：
		<input type="text" id="address2" value="" style="">
	</p>
	<p>电子邮箱：
		<input type="text" id="email" value="" style="">
	</p>
	<p>邮编：
		<input type="text" id="postcode" value="" style="">
	</p>
	<p>手机号码：
		<input type="text" id="mobile" value="" style="">
		<small style="color:red;">(必填)</small>
	</p>
	<p>最佳送货时间：
		<input type="text" id="sendtime" value="" style="width: 14rem;">
	</p>

	<div id="submit" class="details" style="    width: 100%;
    height: 3.15rem;
    background: #231916;
    color: #FFFFFF;
    font-size: 1rem;
    text-align: center;
    line-height: 3.15rem;
    margin-top: 1rem;
    border-radius: .25rem;">
		保存
	</div>
</div>

<div class="call">
	<a href="tel:4006667899" style="    color: #fff;"><img src="/static/shop/mobile/img/tel111.png" /></a>
	<a href="tel:4006667899" style="    color: #fff;"><p>收藏热线：400 666 7899</p></a>
</div>

<div class="footer">
	{include file="public:single"/}
</div>
<p class="icp">网站备案号：晋ICP备10002939号</p>
</body>
<script src="/static/shop/account/js/jquery-3.2.1-min.js"></script>
<script src="/static/shop/account/js/PhoneJs.js"></script>

</html>

<script type="text/javascript" src="/static/shop/js/address/worldAddress.js"></script>
<script type="text/javascript" src="/static/shop/js/address/TestAddress.js"></script>
<script type="text/javascript" src="/static/shop/js/address/TestChooseAddress.js"></script>
<script>
    $(document).ready(function () {
        $("#submit").on("click", function () {
            if($("#s1").val() =='中国'){
                if($('#id_citySelect').find("option:selected").text() == '请选择城市'){
                    return alert('请选择城市');
                }
                if($('#id_citySelect').find("option:selected").text() == '地级市、县'){
                    return alert('请选择城市');
                }
                prov = $('#id_provSelect').find("option:selected").text();
                city = $('#id_citySelect').find("option:selected").text();
            }else{
                if($('#s3').find("option:selected").text() == '请选择城市'){
                    return alert('请选择城市');
                }
                if($('#s3').find("option:selected").text() == '地级市、县'){
                    return alert('请选择城市');
                }
                prov = $('#s2').find("option:selected").text();
                city = $('#s3').find("option:selected").text();
            }
            if(!$("#name").val()){
                return alert('请输入收货人姓名');
            }
            if(!$("#address1").val()){
                return alert('请输入详细地址');
            }
            if(!$("#mobile").val()){
                return alert('请输入收货人联系方式');
            }


            $.ajax({
                url: "{:url('shop/account/ajaxaddress')}",
                type: "POST",
                dataType: "JSON",
                data: {
                    country: $("#s1").val(),
                    prov:prov,
                    city:city,
                    name: $("#name").val(),
                    address1:$("#address1").val(),
                    address2:$("#address2").val(),
                    email:$("#email").val(),
                    postcode:$("#postcode").val(),
                    mobile:$("#mobile").val(),
                    sendtime:$("#sendtime").val(),
                },
                success: function (data) {
                    alert(data.msg);
                    if (data.code == "0") {
                        window.location.href = "{:url('shop/account/address')}";
                    }

                }
            });
        });
    });
</script>

<script type="text/javascript">
    var s = [ "s1", "s2", "s3" ];
    var opt0 = [ "国家", "省份、州", "地级市、县" ];
    function setup() {

        change(0);
    }
</script>
<script type="text/javascript">
    function loadProvince(regionId) {
        $("#id_provSelect").html("");
        $("#id_provSelect").append("<option value=''>请选择省份</option>");
        var jsonStr = getAddress(regionId, 0);
        for ( var k in jsonStr) {
            $("#id_provSelect").append(
                "<option value='"+k+"'>" + jsonStr[k] + "</option>");
        }
        if (regionId.length != 6) {
            $("#id_citySelect").html("");
            $("#id_citySelect").append("<option value=''>请选择城市</option>");
//            $("#id_areaSelect").html("");
//            $("#id_areaSelect").append("<option value=''>请选择区域</option>");
        } else {
            $("#id_provSelect").val(regionId.substring(0, 2) + "0000");

        }
    }

    function loadCity(regionId) {
        $("#id_citySelect").html("");
        $("#id_citySelect").append("<option value=''>请选择城市</option>");
        if (regionId.length != 6) {
//            $("#id_areaSelect").html("");
//            $("#id_areaSelect").append("<option value=''>请选择区域</option>");
        } else {
            var jsonStr = getAddress(regionId, 1);
            for ( var k in jsonStr) {
                $("#id_citySelect").append(
                    "<option value='"+k+"'>" + jsonStr[k] + "</option>");
            }
            if (regionId.substring(2, 6) == "0000") {
//                $("#id_areaSelect").html("");
//                $("#id_areaSelect").append("<option value=''>请选择区域</option>");
            } else {
                $("#id_citySelect").val(regionId.substring(0, 4) + "00");

            }
        }
    }

    function loadArea(regionId) {
//        $("#id_areaSelect").html("");
//        $("#id_areaSelect").append("<option value=''>请选择区域</option>");
        if (regionId.length == 6) {
            var jsonStr = getAddress(regionId, 2);
            for ( var k in jsonStr) {
//                $("#id_areaSelect").append(
//                    "<option value='"+k+"'>" + jsonStr[k] + "</option>");
            }
//            if (regionId.substring(4, 6) != "00") {
//                $("#id_areaSelect").val(regionId);
//            }
        }
    }
    function getCountry() {
        change(1);
        var country = document.getElementById("s1");
        var province = document.getElementById("s2");
        var city = document.getElementById("s3");
        var provSelect = document.getElementById("id_provSelect");
        var citySelect = document.getElementById("id_citySelect");
//        var areaSelect = document.getElementById("id_areaSelect");
        if (country.value == "中国") {
            loadProvince('440116');
            provSelect.style.display = "inline";
            province.style.display = "none";
            city.style.display = "none";
        } else {
            province.style.display = "inline";
            provSelect.style.display = "none";
            citySelect.style.display = "none";
//            areaSelect.style.display = "none";
        }
    }
    function getChinaProv(regionId) {
        document.getElementById("id_citySelect").style.display = "inline";
        loadCity(regionId);
    }
    function getChinaCity(regionId) {
//        document.getElementById("id_areaSelect").style.display = "inline";
//        loadArea(regionId);
    }
    function getProvince() {
        change(2);
        var province = document.getElementById("s2");
        var city = document.getElementById("s3");
        city.style.display = 'inline';
    }
    setup()
</script>